<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.news.entity.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>一个新闻</title>
<%
	manager mg = (manager) session.getAttribute("user");
	Object a1 = request.getParameter("quit");
	if ("t".equals(a1) || mg == null) { //点击退出或者未登录状态
		session.removeAttribute("user");
		//将mg置为空，否则报空指针异常
		mg = new manager(null, null, null);
	}
	news n = (news) request.getAttribute("news");
%>
<style type="text/css">
*{
    margin: 0px;
    padding: 0px;
}
#form_div{
    margin-top:30px;
 	width:800px;
 	height:450px;
 	margin:0px auto;
}
#but_div{
    position:relative;
    width: 200px;
    height: 50px;
    margin: 0px auto;
    top:10px;
}
#form{
    width:800px;
    height:350px;
    border:2px solid gray;
    border-radius:10px;
    margin: 0px auto;
    position: relative;
    top:10px;
    background: white;
    font-size: 17px;
}
.but{
    width:80px;
    height:30px;
    background: gray;
    margin-left: 10px

}
</style>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/oneNew.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/seleAllNews.js"></script>
</head>
<body>
<!-- 页面头部   -->
<header id="header_div">
  <div class="container">
	<div class="logo left">
		<img src="${pageContext.request.contextPath}/img/logo2.jpg" width="700" height="90">
	</div>
	<ul class="right">
	    <li id="info1"><a href="${pageContext.request.contextPath}/view/login/login.jsp">登录？</a></li>
	    <li id="info2"><a href="${pageContext.request.contextPath}/view/login/addMg.jsp">马上注册</a></li>
		<li><a href="${pageContext.request.contextPath}/view/News/addNew.jsp">添加新闻</a></li>
		<li><a href="${pageContext.request.contextPath}/newsServlet/seleByPage/1">查看全部新闻</a></li>
		<li><a href="${pageContext.request.contextPath}/index.jsp">返回主页</a></li>
	</ul>
  </div>
</header>
<br><br>
<!-- 表单部分 -->
<div id="form_div">   
	<form id="form">
		<p>新闻编号：<%=n.getId() %></p>
		<p>标题：<input type="text" id="title" value="<%=n.getTitle() %>" /></p>
		<p>内容：
		     <textarea rows="12" cols="60" id="context"><%=n.getContext() %></textarea>
		</p>
		<p>作者：<input type="text" id="user" value="<%=n.getUser() %>" /></p>
		<p>类别：<select id="sort"  name="sort">
                 <option><%=n.getSort() %></option>
                 <option>生活</option>
                 <option>娱乐</option>
                 <option>军事</option>
                 <option>政治</option>
                 <option>国际</option>
                 <option>社会</option>
             </select></p>
		<p>上传时间：<%=n.getTime() %></p>
	</form>
	<div id="but_div">
	    <button class="but" onclick="addNew()">确认修改</button>
	    <button class="but"><a href="${pageContext.request.contextPath}/newsServlet/seleByPage/1">返回</a></button>
	</div>
</div>
<!--页脚部分-->
<div id="footer">
	<div class="container">
		<p>
			<img src="img/i-f-logo.png"> <span>@2020 北京市xxxxxxx</span>
			 <a href="#">版权说明</a> <a href="#">版权说明</a> <a href="#">版权说明</a> 
			 <a href="#">版权说明</a> <a href="#">版权说明</a>
		</p>
	</div>
</div>
<script type="text/javascript">
//进行登录判断
$(function () {
    var uname="<%=mg.getUname()%>";
    var uid="<%=mg.getId()%>";
    //判断用户名是否为空
    if(!isEmpty(uname)){
    	$("#info1").html("<span>欢迎您！&nbsp"+uname+"<a href='/NewsManager_SSM/index.jsp?quit=t'> [退出]</a></span>");
    	$("#info2").text("");
    }
});

</script>
</body>
</html>